/*
 * ShoppingCartShopCarriageHolder.java
 * business
 *
 * Created by ChenTao on 2017/2/14.
 *
 * Copyright (c) 2017年 yidiandao. All rights reserved.
 */

package com.yidiandao.business.ui.widget.listview.viewholder;

import android.text.SpannableString;
import android.text.SpannableStringBuilder;
import android.view.View;
import android.widget.TextView;

import com.yidiandao.business.R;
import com.yidiandao.business.ui.widget.listview.ViewHolder;
import com.yidiandao.business.utils.TextRenderUtils;
import com.yidiandao.business.utils.UIUtils;

/**
 * 购物车-店铺-配送方式-ViewHolder
 * <p>
 * <p>Created by ChenTao(chentao7v@gmail.com) on 2017/2/14 9:19
 */
public class ShoppingCartShopCarriageHolder extends ViewHolder {

    private TextView tvCarriage;

    private TextView tvFreeLine;

    @Override
    protected void initView(View rootView) {
        tvCarriage = (TextView) rootView.findViewById(R.id.tv_carriage);
        tvFreeLine = (TextView) rootView.findViewById(R.id.tv_free_line);
    }

    /**
     * 设置店铺的运费
     */
    public void setShopCarriage(float shopCarriage) {
        SpannableStringBuilder builder = new SpannableStringBuilder();

        // 运费：
        SpannableString carriageText = TextRenderUtils.getAbsoluteSizeText(
                UIUtils.getString(R.string.shop_carriage), UIUtils.dp2px(13));

        // 价格  ￥20.00元
        SpannableString carriagePrice = TextRenderUtils.getBeautyPrice(
                shopCarriage + "", null, UIUtils.dp2px(13), UIUtils.dp2px(11));

        builder.append(carriageText);
        builder.append(carriagePrice);

        tvCarriage.setText(builder);
    }

    /**
     * 设置免运费的条件
     */
    public void setCarriageFreeLine(float freeLine) {
        tvFreeLine.setText(UIUtils.getString(R.string.free_line_of_carriage, freeLine));
    }

    @Override
    protected int getItemLayoutId() {
        return R.layout.item_shopping_cart_shop_carriage;
    }
}
